import java.util.Arrays;

public class Test {

    public static void main(String[] args) {
        int []arr = {1,2,3,4,5,6};
        int[] newArr = arr;
        newArr[0] = 10;
        System.out.println("newArr:"+ Arrays.toString(arr));

        arr[0] = 1;
//        使用copyOf方法进行拷贝,将newArr刷新成了一个新数组
        newArr = Arrays.copyOf(arr,arr.length);
        System.out.println("newArr:"+ Arrays.toString(newArr));

        arr[0]=10;
        System.out.println("arr:"+Arrays.toString(arr));
        System.out.println("newArr:"+Arrays.toString(newArr));

//        部分拷贝
        int [] newArr2=Arrays.copyOfRange(arr,2,5);    /*不包括2，包括5*/
        System.out.println("newArr2:"+Arrays.toString(newArr2));

    }
}
